package com.hzvdvmc.autosale.socket;

import com.hzvdvmc.autosale.seriaport.SerialCallback;
import com.hzvdvmc.autosale.seriaport.SerialClientManager;
import com.hzvdvmc.autosale.seriaport.SerialCmdEnum;
import com.hzvdvmc.autosale.util.StringUtil;
import com.hzvdvmc.autosale.util.ToastUtils;

/**
 * Created by william on 2018/4/19.
 */

public class TempetureUtil {
    public static String current = "20";

    public static String getCurrentTem() {
        getInfo("00");
        return current;
    }

    private static void getInfo(String code) {
        SerialClientManager manager = new SerialClientManager();
        manager.setCallback(SerialCmdEnum.MACHINE_STATE, new SerialCallback() {
            @Override
            public void onSuccess(String cmd, String data,String tuneNO, String orderNO) {
                current = data.substring(4, 5);
            }

            @Override
            public void onFile(String msg,String tuneNO, String orderNO) {
                ToastUtils.showShort("获取失败，" + msg);
            }
        });
        manager.setData(code);
        manager.execute();
    }
}
